import 'package:base_plugin/base_plugin.dart';
import 'package:finance_app/generated/l10n.dart';
import 'package:finance_app/src/common/app_colors.dart';
import 'package:finance_app/src/widgets/button/normal_mini_button.dart';
import 'package:flutter/material.dart';

import 'default_bottom_sheet.dart';

showCancelSubscriptionBottomSheet(BuildContext context,
        {VoidCallback onYes, VoidCallback onNo}) =>
    showJudgeBottomSheet(context, '''Are you sure you want
to cancel subscription?''');

// 是否删除计量单位
showDeleteUOMJudgeBottomSheet(BuildContext context,
        {VoidCallback onYes, VoidCallback onNo}) =>
    showJudgeBottomSheet(context, S.current.do_you_want_to_delete_uom);

// 是否标记配送地址
showMarkTheItemsAsDeliveredAsJudgeBottomSheet(BuildContext context,
        {VoidCallback onYes, VoidCallback onNo}) =>
    showJudgeBottomSheet(
        context, S.current.do_you_want_to_mark__the_items_as_delivered);

// 是否上传银行记录
showUploadBankRecordsJudgeBottomSheet(BuildContext context,
        {VoidCallback onYes, VoidCallback onNo}) =>
    showJudgeBottomSheet(
        context, S.current.do_you_want_to_upload_your_bank_records);

/// 登出
showLogoutJudgeBottomSheet(BuildContext context,
        {VoidCallback onYes, VoidCallback onNo}) =>
    showJudgeBottomSheet(context, S.current.do_you_want_to_logout);

/// 删除工资单
showDeletePayrollJudgeBottomSheet(BuildContext context,
        {VoidCallback onYes, VoidCallback onNo}) =>
    showJudgeBottomSheet(
        context, S.current.do_you_want_to_delete_this_payroll_request);

/// 添加 联系人
showImportContactJudgeBottomSheet(BuildContext context,
        {VoidCallback onYes, VoidCallback onNo}) =>
    showJudgeBottomSheet(
        context, S.current.do_you_want_to_import_contact_from_your_phone_book);

/// 添加 adjust note
showAdditionalNoteJudgeBottomSheet(BuildContext context,
        {VoidCallback onYes, VoidCallback onNo}) =>
    showJudgeBottomSheet(
        context, S.current.do_you_want_to_add_any_additional_notes);

showReimburseLaterJudgeBottomSheet(BuildContext context,
        {VoidCallback onYes, VoidCallback onNo}) =>
    showJudgeBottomSheet(
      context,
      S.current.do_you_want_to_add_this_reimbursement_to_payslip,
    );

showBulkReimburseLaterJudgeBottomSheet(BuildContext context,
        {VoidCallback onYes, VoidCallback onNo}) =>
    showJudgeBottomSheet(
      context,
      S.current.do_you_want_to_add_selected_reimbursement_to_payslip,
    );

showSwitchCompanyJudgeBottomSheet(BuildContext context,
        {VoidCallback onYes, VoidCallback onNo}) =>
    showJudgeBottomSheet(
      context,
      S.current.would_you_like_to_switch_to_the_selected_company,
    );

/// judge 是或否确认底部对话框
showJudgeBottomSheet(BuildContext context, String content,
        {VoidCallback onYes, VoidCallback onNo}) =>
    showDefaultBottomSheet(
      context,
      child: _JudgeWidget(
        onYes: onYes,
        onNo: onNo,
        content: content,
      ),
      isScrollControlled: true,
    );

class _JudgeWidget extends StatelessWidget {
  final VoidCallback onYes;
  final VoidCallback onNo;
  final String content;

  const _JudgeWidget({Key key, this.onYes, this.onNo, this.content})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    final titleStyle = TextStyle(
      color: aceBlackColor,
      fontSize: getSp(22),
      fontWeight: FontWeight.w700,
      height: 24 / 22,
    );
    return Padding(
      padding: EdgeInsets.only(
        left: getDp(36),
        right: getDp(36),
      ),
      child: Column(
        mainAxisSize: MainAxisSize.min,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          Text(
            content,
            style: titleStyle,
            textAlign: TextAlign.center,
          ),
          SizedBox(
            height: getDp(30),
          ),
          Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              NormalMiniButton(
                onTap: onYes ??
                    () {
                      Navigator.of(context).pop(true);
                    },
                title: S.current.yes,
              ),
              SizedBox(
                width: getDp(30),
              ),
              NormalMiniButton(
                onTap: onNo ??
                    () {
                      Navigator.of(context).pop(false);
                    },
                title: S.current.no,
              ),
            ],
          ),
        ],
      ),
    );
  }
}
